﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Manager_MaterialBidMyList : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        TestPurview(HttpContext.Current, 1);
        if (!Page.IsPostBack)
        {
            BLL.MaterialOrderBLL bll = new BLL.MaterialOrderBLL();
            Model.SessionUser sUser = this.getSessionUser(HttpContext.Current);

            this.PageOn1.pageSize = 10;
            this.PageOn1.total = bll.GetMyListCount(sUser.uid);
            BindList();

            
        }
    }
    private void BindList()
    {
        BLL.MaterialOrderBLL bll = new BLL.MaterialOrderBLL();
        Model.SessionUser sUser = this.getSessionUser(HttpContext.Current);
        if(this.PageOn1.currentPage>0)
            this.rptList.DataSource = bll.GetMyList(10, this.PageOn1.currentPage, sUser.uid);
        this.rptList.DataBind();
    }

    protected void PageOn1_OnPangeChanged(object sender, EventArgs e)
    {
        BindList();
    }
    protected void Delete_Click(object sender, EventArgs e)
    {
        LinkButton lb = (LinkButton)sender;
        if (Common.Help.IsNumber(lb.CommandArgument.ToString()))
        {
            BLL.MaterialOrderBLL bll = new BLL.MaterialOrderBLL();
            Model.SessionUser sUser = this.getSessionUser(HttpContext.Current);
            if (bll.Delete(sUser.uid, int.Parse(lb.CommandArgument.ToString())))
            {
                Common.Jscript.AjaxAlert(this,"删除成功！");
                this.PageOn1.total -= 1;
                BindList();
            }
            else
            {
                Common.Jscript.AjaxAlert(this,"删除失败！");
            }
        }
        else
        {
            Common.Jscript.Alert("参数错误");
        }
    }
}
